﻿Imports ajayumi.develop.win32.WebResourcesCatcher.Components

Module GlobalMember
    ' ''' <summary>
    ' ''' 下载文件保存目录
    ' ''' </summary>
    'Public o_SaveFileDir As String = String.Empty
    ' ''' <summary>
    ' ''' 是否自动下载
    ' ''' </summary>
    ' ''' <remarks></remarks>
    'Public o_IsAutoDownload As Boolean = False
    ' ''' <summary>
    ' ''' 检索条件，图片宽度，符合宽度的才保留
    ' ''' </summary>
    ' ''' <remarks></remarks>
    'Public o_Width As Integer = 800
    ' ''' <summary>
    ' ''' 检索条件，图片高度，符合宽度的才保留
    ' ''' </summary>
    ' ''' <remarks></remarks>
    'Public o_Height As Integer = 600
    ' ''' <summary>
    ' ''' 是否开启站内搜索
    ' ''' </summary>
    ' ''' <remarks></remarks>
    'Public o_IsInternal As Boolean = True
    ' ''' <summary>
    ' ''' 匹配模式
    ' ''' </summary>
    ' ''' <remarks></remarks>
    'Public o_MatchMode As MatchMode = MatchMode.OR
    ' ''' <summary>
    ' ''' 是否显示控制台的调试窗口
    ' ''' </summary>
    'Public o_IsDebug As Boolean = True

    ''' <summary>
    ''' 获取标准的目录路径，以 \ 结尾
    ''' </summary>
    ''' <param name="dir"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetStandardDir(ByVal dir As String) As String
        Dim _TempStr As String = dir

        If String.IsNullOrEmpty(_TempStr) Then
            _TempStr = Application.StartupPath
        End If

        If _TempStr.EndsWith("\") = False Then
            _TempStr &= "\"
        End If
        _TempStr = String.Concat(_TempStr, DateTime.Now.ToString("yyyyMMdd"), "\")

        Return _TempStr
    End Function

    Public Function GetStandardUrl(ByVal url As String) As String
        Dim _TempStr As String = url

        '判断是否有 http:// 开头，如果没有则添加 
        If _TempStr.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) = False Then
            _TempStr = String.Concat("http://", _TempStr)
        End If

        Return _TempStr
    End Function

    ''' <summary>
    ''' 创建保存文件的文件夹
    ''' </summary>
    ''' <param name="saveFileDir"></param>
    ''' <remarks></remarks>
    Public Sub CreateSaveFileFolder(ByVal saveFileDir As String)
        Try
            If System.IO.Directory.Exists(saveFileDir) = False Then
                System.IO.Directory.CreateDirectory(saveFileDir)
            End If
        Catch ex As Exception
            MsgBox(String.Format("创建保存图片文件夹{0}发生错误！{2}错误信息：{2}{1}", saveFileDir, ex.Message, vbCrLf), MsgBoxStyle.Exclamation)
        End Try
    End Sub



End Module
